//
//  BQShopHeaderView.m
//  BeeQuick
//
//  Created by student on 2017/7/13.
//  Copyright © 2017年 BecomeRich. All rights reserved.
//

#import "BQShopHeaderView.h"
#import <Masonry.h>
#define KMagin 15
#define KTrailing 30
@implementation BQShopHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        [self setupUI];
    }
    return self;
}

- (void)setupUI{
    
    UIImageView *topLineImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"v2_shoprail"]];
    [self addSubview:topLineImageView];
    [topLineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.trailing.equalTo(self);
    }];
    UILabel *getLable = [[UILabel alloc]init];
    getLable.text = @"收货人";
    getLable.font = [UIFont systemFontOfSize:13];
    [self addSubview:getLable];
    [getLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.equalTo(self).offset(KMagin);
    }];
    UILabel *nameLabel = [[UILabel alloc]init];
    nameLabel.text = @"      维尼的小熊";
    nameLabel.textAlignment = NSTextAlignmentLeft;
    nameLabel.font = [UIFont systemFontOfSize:13];
    [self addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(getLable);
        make.leading.equalTo(getLable.mas_trailing).offset(KTrailing);
    }];
    UILabel *phoneLabel = [[UILabel alloc]init];
    phoneLabel.text = @"电  话";
    phoneLabel.font = [UIFont systemFontOfSize:13];
    [self addSubview:phoneLabel];
    [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(getLable);
        make.top.equalTo(getLable.mas_bottom).offset(KMagin);
    }];
    UILabel *numLable = [[UILabel alloc]init];
    numLable.text = @"      13888888888";
    numLable.textAlignment = NSTextAlignmentLeft;
    numLable.font = [UIFont systemFontOfSize:13];
    [self addSubview:numLable];
    [numLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(phoneLabel);
        make.leading.equalTo(phoneLabel.mas_trailing).offset(KTrailing);
    }];
    UILabel *atrLabel = [[UILabel alloc]init];
    atrLabel.text = @"收货地址";
    atrLabel.font = [UIFont systemFontOfSize:13];
    [self addSubview:atrLabel];
    [atrLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(phoneLabel.mas_bottom).offset(KMagin);
        make.leading.equalTo(phoneLabel);
    }];
    UILabel *showAtrLable = [[UILabel alloc]init];
    showAtrLable.text = @"上海市浦东新区航头镇航都路18号";
    showAtrLable.textAlignment = NSTextAlignmentLeft;
    showAtrLable.font = [UIFont systemFontOfSize:13];
    [self addSubview:showAtrLable];
    [showAtrLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(atrLabel);
        make.leading.equalTo(atrLabel.mas_trailing).offset(KTrailing);
    }];
    UIImageView *bottomImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"v2_shoprail"]];
    [self addSubview:bottomImageView];
    [bottomImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self).offset(-15);
        make.trailing.leading.equalTo(self);
    }];
    UIImageView *btoImageView = [[UIImageView alloc]init];
    btoImageView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self addSubview:btoImageView];
    [btoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bottomImageView.mas_bottom);
        make.leading.bottom.trailing.equalTo(self);
    }];
    UIImageView *rightView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"icon_go"]];
    rightView.transform = CGAffineTransformScale(rightView.transform, 1.5, 1.5);
    [self addSubview:rightView];
    [rightView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.trailing.equalTo(self).offset(-16);
    }];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]init];
    [self addGestureRecognizer:tap];
    [tap addTarget:self action:@selector(tapAction)];
}
- (void)tapAction{
    if (self.headerBlock != nil) {
        self.headerBlock();
    }
}
@end
